Repository navigation
create_dem: make sure the DEM really gets WGS84 ellipsoidal heights - #161
Open
alhandwerger wants to merge 2 commits into
Open
alhandwerger wants to merge 2 commits into
alhandwerger wants to merge 2 commits into
Conversation
sardem converts Copernicus heights (EGM2008) to ellipsoidal heights with a GDAL warp. When PROJ cannot reach the geoid grid (the default with conda-forge proj), the DEM silently keeps geoid heights, which biases radar-geometry steps such as COMPASS geocoding by roughly dh / tan(look angle). Wrap the sardem call in a scoped context that enables PROJ network access, verifies the EGM2008 shift at the bbox centre and raises otherwise, then restores the previous setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
create_demrelies on sardem to convert Copernicus heights (EGM2008) to WGS84 ellipsoidal heights with a GDAL warp.When PROJ cannot reach the EGM2008 grid, the warp applies no vertical shift and the DEM silently keeps geoid heights,
off by the local undulation (tens of meters). This is the default in a fresh conda-forge or pixi environment: the
projpackage ships no geoid grids, and PROJ network access is off by default.sweets passes this DEM to radar-geometry steps such as COMPASS geocoding. A geoid-height DEM shifts pixels across
track by roughly
dh / tan(look angle)there, with no warning.Fix
create_demnow wraps the sardem call in a small context manager,_geoid_grid_access. It:it is not;
Network access has to be enabled before the first lookup, because PROJ remembers a grid it failed to find for the
rest of the process.
A companion sardem PR (scottstanie/sardem#31) fixes this at the source. Once that is released, this wrapper can be replaced by a minimum
sardem version.
Tests
tests/test_dem.pyruns offline, with the PROJ lookup and sardem mocked:create_demraises without calling sardem when the shift is unavailable;Both tests fail without the fix. The rest of the suite is unchanged locally. One test in
test_download_search.pyerrors both before and after, from an
aiohttp/cassette version mismatch unrelated to this change.🤖 Generated with Claude Code